import { getListCollect } from "../../utils/config";
import store from "../../utils/factory";

Page({
  data: {
    list: [],
    mode: "",
    noData: false
  },
  onLoad: function (e) {
    console.log(e.type);
    if (e) {
      this.setData({
        mode: e.type
      });
      store.set("mode", e.type);
    }
  },
  onShow() {
    this.getListCollect();
  },
  choice(e){
    let address = e.currentTarget.dataset.address;
    console.log(address)
    store.set("delivery",address);
    wx.navigateBack({
      delta: 1
    });
  },
  getListCollect() {
    getListCollect({
      page: 1, limit: 99
    }).then(res => {
      if (res.data.length == 0) {
        this.setData({
          noData: true
        });
      }
      this.setData({
        list: res.data
      });
    });
  },
});
